<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<style type="text/css">
#updateProfile table {
	width: 100%;
	text-align: center;
	padding-top: 100px;
}
#updateProfile th {
	text-align: right;
	padding-right: 10px
}
#updateProfile td {
	text-align: left;
}
#updateProfile .button{
	padding-top: 10px;
	padding-left: 40px;
}
</style>
<script type="text/javascript">
function changeProfile(){
	$('#profile_form').form({
		url : 'user/profile.json',
		data: $('#profile_form').serialize(),
		dataType: 'json',
		onSubmit : function() {
			var flag = $(this).form('validate');
			return flag;
		},
		success : function(data) {
			var json = JSON.parse(data);
			if(json && json.code == 0){
				showInformationMessage('更新成功');
				refreshHeader('${userContext.user.id}');
			}else{
				showErrorMessage('更新失败');
			}
		}
	});
	
	$('#profile_form').submit();
}
</script>

<div id="updateProfile">
<form id="profile_form" method="post">
<input type="hidden" name="userId" value="${userContext.user.id}"/>
<table>
	<tr>
		<th>姓名</th>
		<td><input type="text" name="name" value="${userContext.user.name}" class="easyui-validatebox" data-options="required:false" maxlength="45"/></td>
	</tr>
	<tr>
		<th>电子邮箱</th>
		<td><input type="text" name="email" value="${userContext.user.email}" class="easyui-validatebox" data-options="required:false,validType:'email'" maxlength="45"/></td>
	</tr>
	<tr>
		<td></td>
		<td class="button">
			<span><a href="javascript:void(0)" class="easyui-linkbutton" data-options="width:50" onclick="changeProfile()">确认</a></span>
		</td>
	</tr>
</table>
</form>
</div>